package demo.boat.handler;

import demo.boat.response.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExceptionHandler {
    @ResponseBody
    @ExceptionHandler(Exception.class)
    public Result error(Exception e) {
        e.printStackTrace();
        return Result.error();
    }
    @ExceptionHandler(BussinessException.class)
    @ResponseBody
    public Result error(BussinessException e) {
        e.printStackTrace();
        return Result.error().code(e.getCode()).message(e.getErrMsg());
    }
}
